package cn._2dland.gae.httpclient;

import java.util.HashMap;
import java.util.Map;

public class HttpClientParams {
	public static final String USER_AGENT = "userAgent";
	public static final String FOLLOW_REDIRECT = "followRedirect";
	public static final String USE_CACHES = "useCaches";
	public static final String CLIENT_CHARSET = "clientCharset";

	private Map<String, Object> params;

	public HttpClientParams() {
		params = new HashMap<String, Object>();
		params.put(USER_AGENT, "GAE HttpClient 1.0");
		params.put(FOLLOW_REDIRECT, false);
		params.put(USE_CACHES, false);
		params.put(CLIENT_CHARSET, "utf-8");
	}

	/** 获取所有参数 */
	public Map<String, Object> getParams() {
		return this.params;
	}
	
	public void merge(HttpClientParams params) {
		this.params.putAll(params.getParams());
	}

	/** 用户代理 */
	public String getUserAgent() {
		return (String)params.get(USER_AGENT);
	}
	public void setUserAgent(String value) {
		params.put(USER_AGENT, value);
	}

	/** 自动重定向 */
	public boolean isFollowRedirect() {
		return (Boolean)params.get(FOLLOW_REDIRECT);
	}
	public void setFollowRedirect(boolean value) {
		params.put(FOLLOW_REDIRECT, value);
	}

	/** 缓存 */
	public boolean isUseCaches() {
		return (Boolean)params.get(USE_CACHES);
	}
	public void setUseCaches(boolean value) {
		params.put(USE_CACHES, value);
	}

	/** 客户端字符编码 */
	public String getClientCharset() {
		return (String)params.get(CLIENT_CHARSET);
	}
	public void setClientCharset(String value) {
		params.put(CLIENT_CHARSET, value);
	}
}
